Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Oracle Performance Tuning and Optimization
(Publisher: Macmillan Computer Publishing)
Author(s): Edward Whalen
ISBN: 067230886x
Publication Date: 04/01/96

Bookmark It

Search this book:
 
Previous Table of Contents Next


Understanding How Rollback Segments Work

As a transaction is being processed, information relating to changes made to the data files by that transaction is constantly being written to the rollback segments. It is important that this information be saved because a rollback would require that all data be restored to its original condition.

The information written by the transaction to the rollback segments is called rollback entries. Depending on the length of the transaction and the amount of changes to data, there may be more than one rollback entry for each transaction. These entries are linked together so that they can easily be used in the event of a rollback.

The information stored in the rollback segments includes block information about what blocks have been modified and the data as it was before the change occurred. Remember that the redo log also records information about changes in the database. The redo log along with the rollback segments can restore your data up to the point of failure.

Rollback segments are concurrently used by one or more transactions. You can tune the rollback segments to provide for optimal efficiency and space usage. More transactions sharing rollback segments cause more contention and use space more efficiently. Fewer transactions per rollback segment cause less contention and waste more space.

Oracle maintains what is called a transaction table for each rollback segment. The transaction table stores information about what transactions use that rollback segment and the rollback entries for each change done by these transactions.

Each time a new transaction begins, it is assigned to a rollback segment. This can happen in one of two ways:

  Automatic. Oracle automatically assigns the transaction a rollback segment. The assignment takes place when the first DDL or DML statement is issued. Queries are never assigned rollback segments.
  Manual. The application can manually specify a rollback segment by using the SET TRANSACTION command with the USE ROLLBACK SEGMENT parameter. This arrangement allows the developer to choose the correct size rollback segment for a particular task. The rollback segment is assigned for the duration of the transaction.

At the end of each transaction, when the COMMIT has occurred, the rollback information is released from the rollback segment—but is not deleted, in order to provide read-consistent views for other queries that started before the transaction was committed. To retain this information as long as possible, the rollback segments are written as a circular buffer as described next.

You can think of rollback segments as a sort of circular buffer. A rollback segment must have at least two extents (usually more). When a transaction fills up one extent, it starts using the next extent in sequence. When it gets to the last extent, the transaction continues with extent 1 again, if it is available (see Figure 9.3).


Figure 9.3  A rollback segment.

If the transaction uses the last extent in the segment, it looks to see whether the first extent is available. If not, another extent is created (see Figures 9.4 and 9.5).


Figure 9.4  A rollback segment with all extents used.


Figure 9.5  A rollback segment showing dynamic growth.

The number of extents used for the rollback segments is determined in the definition of the rollback segments when you create them. Rollback segments are created with the following command:

CREATE PUBLIC ROLLBACK SEGMENT rsname
TABLESPACE tsname
STORAGE (
INITIAL 100K
NEXT 100K
OPTIMAL 1500K
MINEXTENTS 15
MAXEXTENTS 100);

In this example, the following values are specified by the user:

  INITIAL: The initial extent is 100K.
  NEXT: The second extent is 100K. With rollback segments, it is always a good idea to make all extents the same size because there is no distinction between different extents.
  OPTIMAL: Set to 800K. This value specifies what you think the optimal size for the rollback segment should be. When extents are no longer needed, they are eliminated until this size is reached.
  MINEXTENTS: Set to 8. The minimum number of extents. This is also the number allocated when the segment is created.
  MAXEXTENTS: Set to 100. The maximum number of extents that can be dynamically allocated.

Initially, there are MINEXTENTS number of extents in the rollback segment. As extents fill up, they are used in a circular fashion, returning to the first extent when all others are filled. If a rollback segment has used all the space in all the extents and MAXEXTENTS has not been reached, another extent is created. If the size of the rollback segment is larger than OPTIMAL and there are unused extents, the unused extents are dropped from the rollback segment.

Both the creation and destruction of rollback segment extents cause overhead in the system. In addition to the overhead created by the addition of extents to a rollback segment, the transaction needing to write into that rollback segment must wait for the extent to be created before it can continue. The following sections explain how to tune your use of rollback segments.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.